﻿@using Ext.Net.MVC;
@using Ext.Net;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Header
{
    <script>
        function deleterecord() {
            if (App.DataGridPanel.getSelectionModel().getSelection()[0] == null) {
                alert('No contact selected');
                return;
            }
            var id = App.DataGridPanel.getSelectionModel().getSelection()[0].get('Forumn');
        }

        function editrecord() {
            if (App.ForumTypeDataGrid.getSelectionModel().getSelection()[0] == null) {
                alert('No record selected');
                return;
            }
            var id = App.ForumTypeDataGrid.getSelectionModel().getSelection()[0].get('ForumTypeId');
            showWindow('Edit Forum Type', '/Forum/EditForumType/' + id, true, 0.85, 0.85);

        }

    </script>
    
    
}

@section ToolbarSection
{
@Html.X().ToolbarTextItem().Text("<h3 style=\"color:blue\">List Forum Type</h3>")
}

@(Html.X().GridPanel()
      .ID("ForumTypeDataGrid")
      .Frame(true)
      .Border(false)
      .Store(
          Html.X().Store()
              .ID("ForumTypeDataStore")
              .Model(
                  Html.X().Model()
                      .IDProperty("ForumTypeId")
                      .Fields(
                          new ModelField("ForumTypeId",ModelFieldType.Int),
                          new ModelField("TypeName"),
                          new ModelField("Description")
                             )
                    )
               .RemoteSort(true)
               .RemotePaging(true)
               .RemoteFilter(true)
               .PageSize(10)
               .Proxy(
                      Html.X().AjaxProxy()
                              .Url(Url.Action("ForumTypeData"))
                              .Reader(Html.X().JsonReader().Root("data"))
                     )
            )
      .ColumnModel(
          Html.X().Column().Text("ID").DataIndex("ForumTypeId").Flex(1),
          Html.X().Column().Text("Name").DataIndex("TypeName").Flex(4),
          Html.X().Column().Text("Description").DataIndex("Description").Sortable(false).Flex(8),
          Html.X().CommandColumn().Text("Edit").Commands(
          Html.X().GridCommand().CommandName("Edit").Icon(Icon.NoteEdit).ToolTip(tt => tt.Text = "Edit Record"))
                .Listeners(ls => ls.Command.Handler = "editrecord();").Flex(1),
          Html.X().CommandColumn().Text("Delete").Commands(
          Html.X().GridCommand().CommandName("Delete").Icon(Icon.Delete).ToolTip(tt => tt.Text = "Delete Record"))
                .Listeners(ls => ls.Command.Handler = "deleterecord();").Flex(1)
                   )
       .TopBar(
              Html.X().Toolbar().Items(items =>
              {

                  items.Add(new LinkButton { Text = "All", Handler = "#{DirectMethods}.CharFilter('');", });

                  items.Add(new ToolbarSpacer());
                  items.Add(new ToolbarSeparator());
                  items.Add(new ToolbarSpacer());

                  items.Add(new LinkButton { Text = "0-9", Handler = "#{DirectMethods}.CharFilter('0');", });

                  items.Add(new ToolbarSpacer());
                  items.Add(new ToolbarSeparator());
                  items.Add(new ToolbarSpacer());

                  items.Add(new LinkButton { Text = "A", Handler = "#{DirectMethods}.CharFilter('A');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "B", Handler = "#{DirectMethods}.CharFilter('B');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "C", Handler = "#{DirectMethods}.CharFilter('C');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "D", Handler = "#{DirectMethods}.CharFilter('D');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "E", Handler = "#{DirectMethods}.CharFilter('E');", });
                  items.Add(new ToolbarSpacer());

                  items.Add(new ToolbarSpacer());
                  items.Add(new ToolbarSeparator());
                  items.Add(new ToolbarSpacer());

                  items.Add(new LinkButton { Text = "F", Handler = "#{DirectMethods}.CharFilter('F');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "G", Handler = "#{DirectMethods}.CharFilter('G');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "H", Handler = "#{DirectMethods}.CharFilter('H');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "I", Handler = "#{DirectMethods}.CharFilter('I');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "J", Handler = "#{DirectMethods}.CharFilter('J');", });
                  items.Add(new ToolbarSpacer());

                  items.Add(new ToolbarSpacer());
                  items.Add(new ToolbarSeparator());
                  items.Add(new ToolbarSpacer());

                  items.Add(new LinkButton { Text = "K", Handler = "#{DirectMethods}.CharFilter('K');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "L", Handler = "#{DirectMethods}.CharFilter('L');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "M", Handler = "#{DirectMethods}.CharFilter('M');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "N", Handler = "#{DirectMethods}.CharFilter('N');", });
                  items.Add(new ToolbarSpacer());

                  items.Add(new ToolbarSpacer());
                  items.Add(new ToolbarSeparator());
                  items.Add(new ToolbarSpacer());

                  items.Add(new LinkButton { Text = "O", Handler = "#{DirectMethods}.CharFilter('O');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "P", Handler = "#{DirectMethods}.CharFilter('P');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "Q", Handler = "#{DirectMethods}.CharFilter('Q');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "R", Handler = "#{DirectMethods}.CharFilter('R');", });
                  items.Add(new ToolbarSpacer());

                  items.Add(new ToolbarSpacer());
                  items.Add(new ToolbarSeparator());
                  items.Add(new ToolbarSpacer());

                  items.Add(new LinkButton { Text = "S", Handler = "#{DirectMethods}.CharFilter('S');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "T", Handler = "#{DirectMethods}.CharFilter('T');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "U", Handler = "#{DirectMethods}.CharFilter('U');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "V", Handler = "#{DirectMethods}.CharFilter('V');", });
                  items.Add(new ToolbarSpacer());

                  items.Add(new ToolbarSpacer());
                  items.Add(new ToolbarSeparator());
                  items.Add(new ToolbarSpacer());

                  items.Add(new LinkButton { Text = "W", Handler = "#{DirectMethods}.CharFilter('W');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "X", Handler = "#{DirectMethods}.CharFilter('X');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "Y", Handler = "#{DirectMethods}.CharFilter('Y');", });
                  items.Add(new ToolbarSpacer());
                  items.Add(new LinkButton { Text = "Z", Handler = "#{DirectMethods}.CharFilter('Z');", });
                  items.Add(new ToolbarSpacer());

                  items.Add(new ToolbarFill());


                  items.Add(new Button
                  {
                      Text = "<b>Create</b>",
                      Margins = "0 20 0 0",
                      Icon = Icon.Add,
                      OnClientClick = "showWindow('Create Forum Type','/Forum/CreateForumType',true,0.85,0.85);"

                  });

              })
          )
          .BottomBar(Html.X().PagingToolbar()))
